﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;

public class FloatingTextManager : MMSingleton<FloatingTextManager>
{
    public FloatingText floatingTextPrefab;
    public Canvas floatingTextCanvas;
    /// <summary>
    /// 显示浮动伤害
    /// </summary>
    /// <param name="text">显示文字</param>
    /// <param name="location">显示位置</param>
    public void ShowFloatingText(string text, Transform location,float offsetY)
    {
        FloatingText floatingText = Instantiate<FloatingText>(floatingTextPrefab,floatingTextCanvas.transform);
        Vector2 screenPosition = Camera.main.WorldToScreenPoint(new Vector2(location.position.x + Random.Range(-0.2f,0.2f),location.position.y+ offsetY + Random.Range(-0.2f, 0.2f)));
        floatingText.transform.position = screenPosition;
        floatingText.SetText(text);
    }
}
